package com.ljj.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import com.ljj.entity.Score;

import com.ljj.mapper.ScoreMapper;

import com.ljj.service.IScoreService;
import com.ljj.utli.Result;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author liujiju
 * @since 2021-11-19
 */
@CrossOrigin
@RestController
@RequestMapping("/score")
public class ScoreController {

	@Autowired
	IScoreService is;
	@Autowired
	ScoreMapper m;

	/**
	 * 条件查询
	 * 
	 * @param d
	 * @return
	 */
	@RequestMapping("/scoregetList")
	public Object scoregetList(Score e) {
		List<Score> list = is.scoregetList(e);

		e.setLimit(null);
		e.setPage(null);
		List<Score> list1 = is.scoregetList(e);
		return new Result(0, "", list, list1.size());

	}

	/**
	 * 添加
	 * 
	 * @param c
	 * @return
	 */
	@RequestMapping("/scoreadd")
	public Object scoreadd(Score q) {
		System.out.println(q+"eeeee");
		if (m.insert(q) > 0) {
			return new Result(0, "添加成功");
		} else {
			return new Result(1, "添加失败");
		}
	}

	/**
	 * 修改
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping("/scoreupdate")
	public Object scoreupdate(Score d) {
		System.out.println(d+"Eee");
		if (m.updateById(d) > 0) {
			return new Result(0, "修改成功");
		} else {
			return new Result(1, "修改失败");
		}

	}

	/**
	 * 删除
	 * 
	 * @param
	 * @return
	 */
	@RequestMapping("/scoredelete")
	public Object scoredelete(Score d) {
		if (m.deleteById(d) > 0) {
			return new Result(0, "删除成功");
		} else {
			return new Result(1, "删除失败");
		}

	}

}
